<?php 
include("../classes/include.php");
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page admin Gestion des offres de stage</title>
<link rel="stylesheet" href="../javascript/blue/style.css" type="text/css" media="print, projection, screen" />
<script type="text/javascript" src="../javascript/jquery-1.6.1.js"></script>
	<script type="text/javascript" src="../javascript/jquery.tablesorter.js"></script>
	<script type="text/javascript" src="../javascript/jquery.tablesorter.pager.js"></script>

 <script type="text/javascript">

	
	$(document).ready(function() {  
	    // On cr?er notre tablesorter sur l'id mytable  
	    // Et on trie (au d?part) par la premi?re colonne  
	  
			  $("#mytable").tablesorter({widthFixed: true, widgets: ['zebra']})  
	    .tablesorterPager({container: $("#pager"), positionFixed: false});
			});
		
	    // On ajoute la pagination sur l'id #pager  
	
	
	function details(ligne){
var parent = document.getElementById("detail"+ligne).parentNode;
for( var i = 0; i < parent.childNodes.length; i++ ){
 if( parent.childNodes[i].nodeType == 1 && parent.childNodes[i].tagName.toLowerCase() == "div" && parent.childNodes[i].id !="pager"){
	 parent.childNodes[i].style.display="none";
	
}
}

document.getElementById("detail"+ligne).style.display="block";

 }
     
	
	
	</script>
	
<head>
<body>
<form method="post" action="Admin_offre_stage.php">
<table border="1" id="mytable" class="tablesorter" cellspacing="1">
	<thead>
		<tr>
		<th>x</th>
			<th>Num offre</th>
			<th>Num entreprise</th>
			<th>niveau</th>
			<th>Date debut</th>
			<th>mission</th>
			<th>remuneration</th>
			<th>duree</th>
			<th>date depot</th>
			<th>statut</th>
		</tr>
	</thead>
	<tbody>
		<?php

		$listeoffre = new ListeOffre();
		$listeoffre->remplirListe();
		$listeoffre->afficherListeAdmin();

    ?>
		<tbody>

</table>
<div id="pager" class="pager">
<form><img src="../javascript/first.png" class="first"> <img
	src="../javascript/prev.png" class="prev"> <input class="pagedisplay"
	type="text"> <img src="../javascript/next.png" class="next"> <img
	src="../javascript/last.png" class="last"> <select class="pagesize">
	<option selected="selected" value="10">10</option>
	<option value="20">20</option>
	<option value="30">30</option>
	<option value="40">40</option>
</select></form>
<input type="submit" name="suppoffre" value="supprimer"/>
<input type="button" name="ajoutoffre" value="ajouter"/>
<input type="submit" name="valideoffre" value="valider"/>
</div>

</form>
<?php 

//supprimer une ligne 
if(isset($_POST['suppoffre']) && isset($_POST['select'])){

$numero=$_POST['select'];
$requete = new RequeteSQL("DELETE FROM offre where off_num_offre='$numero' ");
$requete->executeQuery();
header("Location: Admin_offre_stage.php" ); 
}

//Valider une offre de stage
if(isset($_POST['valideoffre']) && isset($_POST['select'])){
$requete = new RequeteSQL("select off_statut from offre where off_num_offre='$numero' ");
$requete->executeQuery();
while ($donnees = $requete->fetch()){
    $etat = $donnees['off_statut'];
}
$numero=$_POST['select'];
if($etat == "KO"){
$requete = new RequeteSQL("UPDATE offre SET off_statut='OK' where off_num_offre='$numero' ");
$requete->executeQuery();
 
}else{
$requete = new RequeteSQL("UPDATE offre SET off_statut='KO' where off_num_offre='$numero' ");
$requete->executeQuery();
}
header("Location: Admin_offre_stage.php" );
}
?>
</body>
</html>		
